{% import "bootstrap/wtf.html" as wtf %}
{% extends 'homemodel.html' %}


{% block styles %}
{{super()}}
<link rel="stylesheet" href="{{url_for('static',filename='editormd.min.css')}}" />
{% endblock %}

{% block title %}
edict passage
{% endblock %}

{% block content %}
<div class="container">
    <form action="" method="POST">
        <div class="row">
            <div class="col">
                <h1 class="text-center">Edit Post</h1>

                {% for i in get_flashed_messages()%}
                <div class="alert alert-primary alert-dismissible fade show" role="alert">
                    {{i}}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                {% endfor %}

                {{form.hidden_tag()}}
                {{ wtf.form_field(form.passage_title) }}
            </div>
        </div>
        <div class="row">
            <div class="col-10 border-right-0">
                <div id="editormd" class="editormd">
                    {{form.passage_body}}
                </div>
            </div>
            <div class="col-2 border-left-0">
                <ul class="list-group">
                    <li class="list-group-item">Dear {{current_user.user_name}}！</li>
                    <li class="list-group-item">Time: {{ moment(current_time).format('lll') }}</li>
                </ul>
                {{wtf.form_field(form.submit)}}
            </div>
        </div>
    </form>

</div>
{% endblock %}

{% block scripts%}
{{super()}}
{{ moment.include_moment() }}
{{ moment.locale('zh-cn') }}

<script src="{{url_for('static',filename='editormd.min.js')}}"></script>
<script type="text/javascript">
    var testEditor;
    testEditor = editormd("editormd", {
        placeholder: '本编辑器支持Markdown编辑，左边编写，右边预览', //默认显示的文字，这里就不解释了
        width: "95%",
        height: 500,
        syncScrolling: "single",
        path: "{{url_for('static',filename='editor/lib/')}}",
        theme: "light", //工具栏主题
        previewTheme: "light", //预览主题
        editorTheme: "base16-light", //编辑主题
        saveHTMLToTextarea: true,
        emoji: false,
        taskList: true,
        tocm: true, // Using [TOCM]
        tex: true, // 开启科学公式TeX语言支持，默认关闭
        flowChart: true, // 开启流程图支持，默认关闭
        sequenceDiagram: true, // 开启时序/序列图支持，默认关闭,
        toolbarIcons: function () { //自定义工具栏，后面有详细介绍
            return editormd.toolbarModes['simple']; // full, simple, mini
        }
    });
</script>
{% endblock %}